import java.util.Scanner;

public class Three {
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        char[] str=in.next().toCharArray();
        long s=0,h=0,y=0;
        for (int i = 0; i < n; i++) {
            char ch=str[i];
            if (ch=='s')
                s+=1;
            else if (ch=='h')
                h+=s;
            else if (ch=='y')
                y+=h;
        }
        System.out.println(y);
    }
}
